import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/vue-admin-template/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}
export function setrole(data) {
  return request({
    url: "/sys/role",
    method: "GET",
    data,
  });
}
export function delrole(id) {
  return request({
    url: `/sys/role/${id}`,
    method: "DELETE",

  });
}
// 添加角色
export function addrole(data) {
  return request({
    url: "/sys/role",
    method: "POST",
    data,
  });
}
// 编辑角色
export function editrole(data) {
  return request({
    url: `/sys/role/${data.id}`,
    method: "PUT",
    data,
  });
}
// 权限列表
// export function qxgl(data) {
//   return request({
//     url: "/sys/permission",
//     method: "GET",
//     data
//   });
// }

export function qxgl(params) {
  return request({
    url: "/sys/permission",
    params,
  });
}

// 新增权限
export function addPermission(data) {
  return request({
    url: '/sys/permission',
    method: 'post',
    data
  })
}

// 更新权限
export function updatePermission(data) {
  return request({
    url: `/sys/permission/${data.id}`,
    method: 'put',
    data
  })
}

// 删除权限
export function delPermission(id) {
  return request({
    url: `/sys/permission/${id}`,
    method: 'delete'
  })
}

// 获取权限详情
export function getPermissionDetail(id) {
  return request({
    url: `/sys/permission/${id}`
  })
}